package StringBuilder;

public class method3StringBuilder {
    public static void main(String[] args) {
//        shiwanciTime();
        StringBuilder();
    }

    private static void StringBuilder() {
        long start = System.currentTimeMillis();
        StringBuilder s = new StringBuilder();
        for (int i = 0; i < 100000; i++) {
            s.append(i);
        }
        long end = System.currentTimeMillis();
        System.out.println(end - start); // 同一台电脑, 从原本45秒变成了15ms.  缩小了3000倍
    }

    private static void shiwanciTime() {
        long time = System.currentTimeMillis(); // 1970年到现在的毫秒值 , c语言的生日就是1970年
        System.out.println(time);

        String s = "";
        for (int i = 0; i < 100000; i++) {
            s+=i; // 45秒
        }

        long time2 = System.currentTimeMillis(); // 1970年到现在的毫秒值
        System.out.println(time2);
    }
}
